#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

ll a, b, T;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	cin >> a >> b;
	if(a == b) return puts("1"), 0;
	per(i, 60, 0) if((a >> i & 1ll) != (b >> i & 1ll)) {
		rep(j, i + 1, 60) a ^= (a >> j & 1ll) << j;
		rep(j, i + 1, 60) b ^= (b >> j & 1ll) << j;
		T = 1ll << i; break;
	}
	ll ans = T - a;
	int p = -1;
	rep(i, 0, 60) if(T + (1ll << i) <= b) p = i;
	ll A1 = T, A2 = T + (1ll << p + 1) - 1;
	ll B1 = T + a, B2 = 2 * T - 1;
	ans += A2 - A1 + 1 + B2 - B1 + 1;
	ans -= max(min(B2, A2) - max(B1, A1) + 1, 0ll);
	cout << ans << endl;
	return 0;
}
